package com.qianfeng.dbsm.admin.util;

import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 功能说明
 * 输出信息转json格式的工具类
 * @author 袁俊杰
 * @date 2022-11-10 20:39:36
 */
public class ResponseUtil {

    public static void writeJson(HttpServletResponse response, Object data){
        response.setCharacterEncoding("utf-8");
        response.setContentType("application/json");
        try {
            response.getWriter().write(JSONObject.toJSONString(data));
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
